#include "glwidget.h"

#include <QMouseEvent>
#include <QDebug>

GLWidget::GLWidget(QWidget *parent) :
    QGLWidget(parent)
{
}

void GLWidget::initializeGL()
{
    glClearColor(0.0, 0.0, 0.0, 1.0);
    glMatrixMode(GL_PROJECTION);
    glLoadIdentity();
    glOrtho(-480.0, 480.0, -270.0, 270.0, -10.0, 10.0);
    glMatrixMode(GL_MODELVIEW);
}

void GLWidget::paintGL()
{
    glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);

    glColor3f(1.0,1.0,1.0);
    glBegin(GL_QUADS);
    glVertex2f(-50.0, -50.0);
    glVertex2f( 50.0, -50.0);
    glVertex2f( 50.0,  50.0);
    glVertex2f(-50.0,  50.0);
    glEnd();
}

void GLWidget::mousePressEvent(QMouseEvent *event)
{
    // Mapear a posição do widget para a posição da câmera
    qDebug() << event->pos();
    qDebug() << this->width() << " " << this->height();
}
